import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import ElasticNet
from sklearn.datasets import make_regression

X, y = make_regression(n_samples=100, n_features=1, noise=10, random_state=42)

elastic_net = ElasticNet(alpha=0.5, l1_ratio=0.5, random_state=42)

elastic_net.fit(X, y)

y_pred = elastic_net.predict(X)

plt.scatter(X, y, label='Actual Data', color='b')
plt.plot(X, y_pred, label='Elastic Net Regression', color='r')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.title('Elastic Net Regression')
plt.show()

print("Elastic Net Coefficients:")
print("Intercept:", elastic_net.intercept_)
print("Coefficient:", elastic_net.coef_)
